<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        /*
        Proxy代理：代码中的中间商、代理商，而且是可以赚差价的中间商
        Proxy本身是一个构造函数，所以在创建时要使用new
        new Proxy（被代理的对象/原对象，{配置项，配置一些赚差价的行为}）
        */
       var user = {
        title :'小飞',
        age:11
       }
      var newUser = new Proxy( user,{
        get(target, key, receiver){
            console.log('getter');
            return target[key]
        },//获取操作
        set(target, key, receiver,values){
            target[key] = receiver
            console.log('setter');
            
        }//修改操作
       })

       console.log(user);
       console.log(newUser);
       console.log(newUser.title);
       console.log(newUser.age);
       newUser.title = '八嘎'
       console.log(newUser.title);
       console.log();



    </script>
</body>
</html>